﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Runtime.CompilerServices;
using Autodesk.Revit.DB;
using HYCodeBase.Math;
using HYRevitCode.XYZUtility;
using Microsoft.CSharp.RuntimeBinder;

namespace HYRevitCode.ElementCreatUtility.MultilineTextCreat
{
	public class MultilineText
	{
		public static bool CreateMultilintText(Autodesk.Revit.DB.Document useDoc, Autodesk.Revit.DB.View useView, TextLocation location, TextNoteType useTextType, double rowPitch, List<string> lstText, out double dWidth, out double dHeight, bool bIfGruopTheText = true, bool ifIsSubTransaction = false)
		{
			rowPitch = UnitUtility.MMToFeet(rowPitch);
			dWidth = 0.0;
			dHeight = 0.0;
			object obj = null;
			if (useView == null || (!(useView is ViewPlan) && !(useView is ViewSection) && !(useView is ViewDrafting)))
			{
				return false;
			}
			bool result = false;
            //try
            //{
            //    if (!ifIsSubTransaction)
            //    {
            //        obj = new Transaction(useDoc, "create");
            //    }
            //    else
            //    {
            //        obj = new SubTransaction(useDoc);
            //    }
            //    if (MultilineText.<>o__0.<>p__0 == null)
            //    {
            //        MultilineText.<>o__0.<>p__0 = CallSite<Action<CallSite, object>>.Create(Binder.InvokeMember(CSharpBinderFlags.ResultDiscarded, "Start", null, typeof(MultilineText), new CSharpArgumentInfo[]
            //        {
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
            //        }));
            //    }
            //    MultilineText.<>o__0.<>p__0.Target(MultilineText.<>o__0.<>p__0, obj);
            //    List<TextNote> lstTextNote;
            //    bool flag = TextColl.CreatTextCollByType(useDoc, useView, location.Align, useTextType, lstText, out lstTextNote);
            //    useDoc.Regenerate();
            //    if (flag)
            //    {
            //        TextColl.SetPosition(useView, lstTextNote, rowPitch);
            //        MultilineText.Finish(useDoc, lstTextNote, location, useView, rowPitch, out dWidth, out dHeight, bIfGruopTheText);
            //    }
            //    if (MultilineText.<>o__0.<>p__1 == null)
            //    {
            //        MultilineText.<>o__0.<>p__1 = CallSite<Action<CallSite, object>>.Create(Binder.InvokeMember(CSharpBinderFlags.ResultDiscarded, "Commit", null, typeof(MultilineText), new CSharpArgumentInfo[]
            //        {
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
            //        }));
            //    }
            //    MultilineText.<>o__0.<>p__1.Target(MultilineText.<>o__0.<>p__1, obj);
            //    result = true;
            //}
            //catch (Exception)
            //{
            //    if (MultilineText.<>o__0.<>p__6 == null)
            //    {
            //        MultilineText.<>o__0.<>p__6 = CallSite<Func<CallSite, object, bool>>.Create(Binder.UnaryOperation(CSharpBinderFlags.None, ExpressionType.IsTrue, typeof(MultilineText), new CSharpArgumentInfo[]
            //        {
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
            //        }));
            //    }
            //    Func<CallSite, object, bool> target = MultilineText.<>o__0.<>p__6.Target;
            //    CallSite <>p__ = MultilineText.<>o__0.<>p__6;
            //    if (MultilineText.<>o__0.<>p__2 == null)
            //    {
            //        MultilineText.<>o__0.<>p__2 = CallSite<Func<CallSite, object, object, object>>.Create(Binder.BinaryOperation(CSharpBinderFlags.None, ExpressionType.NotEqual, typeof(MultilineText), new CSharpArgumentInfo[]
            //        {
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.Constant, null),
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
            //        }));
            //    }
            //    object obj2 = MultilineText.<>o__0.<>p__2.Target(MultilineText.<>o__0.<>p__2, null, obj);
            //    if (MultilineText.<>o__0.<>p__5 == null)
            //    {
            //        MultilineText.<>o__0.<>p__5 = CallSite<Func<CallSite, object, bool>>.Create(Binder.UnaryOperation(CSharpBinderFlags.None, ExpressionType.IsFalse, typeof(MultilineText), new CSharpArgumentInfo[]
            //        {
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
            //        }));
            //    }
            //    object arg2;
            //    if (!MultilineText.<>o__0.<>p__5.Target(MultilineText.<>o__0.<>p__5, obj2))
            //    {
            //        if (MultilineText.<>o__0.<>p__4 == null)
            //        {
            //            MultilineText.<>o__0.<>p__4 = CallSite<Func<CallSite, object, object, object>>.Create(Binder.BinaryOperation(CSharpBinderFlags.BinaryOperationLogical, ExpressionType.And, typeof(MultilineText), new CSharpArgumentInfo[]
            //            {
            //                CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //                CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
            //            }));
            //        }
            //        Func<CallSite, object, object, object> target2 = MultilineText.<>o__0.<>p__4.Target;
            //        CallSite <>p__2 = MultilineText.<>o__0.<>p__4;
            //        object arg = obj2;
            //        if (MultilineText.<>o__0.<>p__3 == null)
            //        {
            //            MultilineText.<>o__0.<>p__3 = CallSite<Func<CallSite, object, object>>.Create(Binder.InvokeMember(CSharpBinderFlags.None, "HasStarted", null, typeof(MultilineText), new CSharpArgumentInfo[]
            //            {
            //                CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
            //            }));
            //        }
            //        arg2 = target2(<>p__2, arg, MultilineText.<>o__0.<>p__3.Target(MultilineText.<>o__0.<>p__3, obj));
            //    }
            //    else
            //    {
            //        arg2 = obj2;
            //    }
            //    if (target(<>p__, arg2))
            //    {
            //        if (MultilineText.<>o__0.<>p__7 == null)
            //        {
            //            MultilineText.<>o__0.<>p__7 = CallSite<Action<CallSite, object>>.Create(Binder.InvokeMember(CSharpBinderFlags.ResultDiscarded, "RollBack", null, typeof(MultilineText), new CSharpArgumentInfo[]
            //            {
            //                CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
            //            }));
            //        }
            //        MultilineText.<>o__0.<>p__7.Target(MultilineText.<>o__0.<>p__7, obj);
            //    }
            //    result = false;
            //}
			return result;
		}

		public static bool CreateMultilintText(Autodesk.Revit.DB.Document useDoc, Autodesk.Revit.DB.View useView, TextLocation location, string font, double size, double rowPitch, List<string> lstText, out double dWidth, out double dHeight, bool bIfGruopTheText = true, bool ifIsSubTransaction = false)
		{
			rowPitch = UnitUtility.MMToFeet(rowPitch);
			dWidth = 0.0;
			dHeight = 0.0;
			object obj = null;
			if (useView == null || (!(useView is ViewPlan) && !(useView is ViewSection) && !(useView is ViewDrafting)))
			{
				return false;
			}
			bool result = false;
        //    try
        //    {
        //        if (!ifIsSubTransaction)
        //        {
        //            obj = new Transaction(useDoc, "create");
        //        }
        //        else
        //        {
        //            obj = new SubTransaction(useDoc);
        //        }
        //        if (MultilineText.<>o__1.<>p__0 == null)
        //        {
        //            MultilineText.<>o__1.<>p__0 = CallSite<Action<CallSite, object>>.Create(Binder.InvokeMember(CSharpBinderFlags.ResultDiscarded, "Start", null, typeof(MultilineText), new CSharpArgumentInfo[]
        //            {
        //                CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
        //            }));
        //        }
        //        MultilineText.<>o__1.<>p__0.Target(MultilineText.<>o__1.<>p__0, obj);
        //        List<TextNote> lstTextNote;
        //        bool flag = TextColl.CreatTextColl(useDoc, useView, location.Align, font, size, lstText, out lstTextNote);
        //        useDoc.Regenerate();
        //        if (flag)
        //        {
        //            TextColl.SetPosition(useView, lstTextNote, rowPitch);
        //            MultilineText.Finish(useDoc, lstTextNote, location, useView, rowPitch, out dWidth, out dHeight, bIfGruopTheText);
        //        }
        //        if (MultilineText.<>o__1.<>p__1 == null)
        //        {
        //            MultilineText.<>o__1.<>p__1 = CallSite<Action<CallSite, object>>.Create(Binder.InvokeMember(CSharpBinderFlags.ResultDiscarded, "Commit", null, typeof(MultilineText), new CSharpArgumentInfo[]
        //            {
        //                CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
        //            }));
        //        }
        //        MultilineText.<>o__1.<>p__1.Target(MultilineText.<>o__1.<>p__1, obj);
        //        result = true;
        //    }
        //    catch (Exception)
        //    {
        //        if (MultilineText.<>o__1.<>p__6 == null)
        //        {
        //            MultilineText.<>o__1.<>p__6 = CallSite<Func<CallSite, object, bool>>.Create(Binder.UnaryOperation(CSharpBinderFlags.None, ExpressionType.IsTrue, typeof(MultilineText), new CSharpArgumentInfo[]
        //            {
        //                CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
        //            }));
        //        }
        //        Func<CallSite, object, bool> target = MultilineText.<>o__1.<>p__6.Target;
        //        CallSite <>p__ = MultilineText.<>o__1.<>p__6;
        //        if (MultilineText.<>o__1.<>p__2 == null)
        //        {
        //            MultilineText.<>o__1.<>p__2 = CallSite<Func<CallSite, object, object, object>>.Create(Binder.BinaryOperation(CSharpBinderFlags.None, ExpressionType.NotEqual, typeof(MultilineText), new CSharpArgumentInfo[]
        //            {
        //                CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.Constant, null),
        //                CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
        //            }));
        //        }
        //        object obj2 = MultilineText.<>o__1.<>p__2.Target(MultilineText.<>o__1.<>p__2, null, obj);
        //        if (MultilineText.<>o__1.<>p__5 == null)
        //        {
        //            MultilineText.<>o__1.<>p__5 = CallSite<Func<CallSite, object, bool>>.Create(Binder.UnaryOperation(CSharpBinderFlags.None, ExpressionType.IsFalse, typeof(MultilineText), new CSharpArgumentInfo[]
        //            {
        //                CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
        //            }));
        //        }
        //        object arg2;
        //        if (!MultilineText.<>o__1.<>p__5.Target(MultilineText.<>o__1.<>p__5, obj2))
        //        {
        //            if (MultilineText.<>o__1.<>p__4 == null)
        //            {
        //                MultilineText.<>o__1.<>p__4 = CallSite<Func<CallSite, object, object, object>>.Create(Binder.BinaryOperation(CSharpBinderFlags.BinaryOperationLogical, ExpressionType.And, typeof(MultilineText), new CSharpArgumentInfo[]
        //                {
        //                    CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
        //                    CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
        //                }));
        //            }
        //            Func<CallSite, object, object, object> target2 = MultilineText.<>o__1.<>p__4.Target;
        //            CallSite <>p__2 = MultilineText.<>o__1.<>p__4;
        //            object arg = obj2;
        //            if (MultilineText.<>o__1.<>p__3 == null)
        //            {
        //                MultilineText.<>o__1.<>p__3 = CallSite<Func<CallSite, object, object>>.Create(Binder.InvokeMember(CSharpBinderFlags.None, "HasStarted", null, typeof(MultilineText), new CSharpArgumentInfo[]
        //                {
        //                    CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
        //                }));
        //            }
        //            arg2 = target2(<>p__2, arg, MultilineText.<>o__1.<>p__3.Target(MultilineText.<>o__1.<>p__3, obj));
        //        }
        //        else
        //        {
        //            arg2 = obj2;
        //        }
        //        if (target(<>p__, arg2))
        //        {
        //            if (MultilineText.<>o__1.<>p__7 == null)
        //            {
        //                MultilineText.<>o__1.<>p__7 = CallSite<Action<CallSite, object>>.Create(Binder.InvokeMember(CSharpBinderFlags.ResultDiscarded, "RollBack", null, typeof(MultilineText), new CSharpArgumentInfo[]
        //                {
        //                    CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
        //                }));
        //            }
        //            MultilineText.<>o__1.<>p__7.Target(MultilineText.<>o__1.<>p__7, obj);
        //        }
        //        result = false;
        //    }
        //    return result;
        //}

        //public static bool CreateMultilintText(Autodesk.Revit.DB.Document useDoc, Autodesk.Revit.DB.View useView, TextLocation location, TextNoteType useTextType, double rowPitch, List<string> lstText, out double dWidth, out double dHeight, out List<TextNote> lstTextNote, bool bIfGruopTheText = true, bool ifIsSubTransaction = false)
        //{
        //    rowPitch = UnitUtility.MMToFeet(rowPitch);
        //    dWidth = 0.0;
        //    dHeight = 0.0;
        //    object obj = null;
        //    lstTextNote = null;
        //    if (useView == null || (!(useView is ViewPlan) && !(useView is ViewSection) && !(useView is ViewDrafting)))
        //    {
        //        return false;
        //    }
        //    bool result;
        //    try
        //    {
        //        if (!ifIsSubTransaction)
        //        {
        //            obj = new Transaction(useDoc, "create");
        //        }
        //        else
        //        {
        //            obj = new SubTransaction(useDoc);
        //        }
        //        if (MultilineText.<>o__2.<>p__0 == null)
        //        {
        //            MultilineText.<>o__2.<>p__0 = CallSite<Action<CallSite, object>>.Create(Binder.InvokeMember(CSharpBinderFlags.ResultDiscarded, "Start", null, typeof(MultilineText), new CSharpArgumentInfo[]
        //            {
        //                CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
        //            }));
        //        }
        //        MultilineText.<>o__2.<>p__0.Target(MultilineText.<>o__2.<>p__0, obj);
        //        List<TextNote> list;
        //        bool flag = TextColl.CreatTextCollByType(useDoc, useView, location.Align, useTextType, lstText, out list);
        //        useDoc.Regenerate();
        //        if (flag)
        //        {
        //            TextColl.SetPosition(useView, list, rowPitch);
        //            MultilineText.Finish(useDoc, list, location, useView, rowPitch, out dWidth, out dHeight, bIfGruopTheText);
        //            lstTextNote = list;
        //        }
        //        if (MultilineText.<>o__2.<>p__1 == null)
        //        {
        //            MultilineText.<>o__2.<>p__1 = CallSite<Action<CallSite, object>>.Create(Binder.InvokeMember(CSharpBinderFlags.ResultDiscarded, "Commit", null, typeof(MultilineText), new CSharpArgumentInfo[]
        //            {
        //                CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
        //            }));
        //        }
        //        MultilineText.<>o__2.<>p__1.Target(MultilineText.<>o__2.<>p__1, obj);
        //        result = true;
        //    }
        //    catch (Exception)
        //    {
        //        if (MultilineText.<>o__2.<>p__6 == null)
        //        {
        //            MultilineText.<>o__2.<>p__6 = CallSite<Func<CallSite, object, bool>>.Create(Binder.UnaryOperation(CSharpBinderFlags.None, ExpressionType.IsTrue, typeof(MultilineText), new CSharpArgumentInfo[]
        //            {
        //                CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
        //            }));
        //        }
        //        Func<CallSite, object, bool> target = MultilineText.<>o__2.<>p__6.Target;
        //        CallSite <>p__ = MultilineText.<>o__2.<>p__6;
        //        if (MultilineText.<>o__2.<>p__2 == null)
        //        {
        //            MultilineText.<>o__2.<>p__2 = CallSite<Func<CallSite, object, object, object>>.Create(Binder.BinaryOperation(CSharpBinderFlags.None, ExpressionType.NotEqual, typeof(MultilineText), new CSharpArgumentInfo[]
        //            {
        //                CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.Constant, null),
        //                CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
        //            }));
        //        }
        //        object obj2 = MultilineText.<>o__2.<>p__2.Target(MultilineText.<>o__2.<>p__2, null, obj);
        //        if (MultilineText.<>o__2.<>p__5 == null)
        //        {
        //            MultilineText.<>o__2.<>p__5 = CallSite<Func<CallSite, object, bool>>.Create(Binder.UnaryOperation(CSharpBinderFlags.None, ExpressionType.IsFalse, typeof(MultilineText), new CSharpArgumentInfo[]
        //            {
        //                CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
        //            }));
        //        }
        //        object arg2;
        //        if (!MultilineText.<>o__2.<>p__5.Target(MultilineText.<>o__2.<>p__5, obj2))
        //        {
        //            if (MultilineText.<>o__2.<>p__4 == null)
        //            {
        //                MultilineText.<>o__2.<>p__4 = CallSite<Func<CallSite, object, object, object>>.Create(Binder.BinaryOperation(CSharpBinderFlags.BinaryOperationLogical, ExpressionType.And, typeof(MultilineText), new CSharpArgumentInfo[]
        //                {
        //                    CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
        //                    CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
        //                }));
        //            }
        //            Func<CallSite, object, object, object> target2 = MultilineText.<>o__2.<>p__4.Target;
        //            CallSite <>p__2 = MultilineText.<>o__2.<>p__4;
        //            object arg = obj2;
        //            if (MultilineText.<>o__2.<>p__3 == null)
        //            {
        //                MultilineText.<>o__2.<>p__3 = CallSite<Func<CallSite, object, object>>.Create(Binder.InvokeMember(CSharpBinderFlags.None, "HasStarted", null, typeof(MultilineText), new CSharpArgumentInfo[]
        //                {
        //                    CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
        //                }));
        //            }
        //            arg2 = target2(<>p__2, arg, MultilineText.<>o__2.<>p__3.Target(MultilineText.<>o__2.<>p__3, obj));
        //        }
        //        else
        //        {
        //            arg2 = obj2;
        //        }
        //        if (target(<>p__, arg2))
        //        {
        //            if (MultilineText.<>o__2.<>p__7 == null)
        //            {
        //                MultilineText.<>o__2.<>p__7 = CallSite<Action<CallSite, object>>.Create(Binder.InvokeMember(CSharpBinderFlags.ResultDiscarded, "RollBack", null, typeof(MultilineText), new CSharpArgumentInfo[]
        //                {
        //                    CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
        //                }));
        //            }
        //            MultilineText.<>o__2.<>p__7.Target(MultilineText.<>o__2.<>p__7, obj);
        //        }
        //        result = false;
        //    }
			return result;
		}

		private static bool Finish(Autodesk.Revit.DB.Document useDoc, List<TextNote> lstTextNote, TextLocation location, Autodesk.Revit.DB.View view, double rowPitch, out double textWidth, out double textHeight, bool bIfGroup)
		{
			textWidth = 0.0;
			textHeight = 0.0;
			bool result;
			try
			{
				List<ElementId> list = new List<ElementId>();
				for (int i = 0; i < lstTextNote.Count; i++)
				{
					list.Add(lstTextNote[i].Id);
				}
				BoundingBoxXYZ multiTextBox = null;
				MultilineText.CalculateBox(view, lstTextNote, rowPitch, out multiTextBox, out textWidth, out textHeight);
				XYZ boundingBoxPoint = MultilineText.GetBoundingBoxPoint(location.Align, multiTextBox, view);
				if (bIfGroup)
				{
					Group group = useDoc.Create.NewGroup(list);
					XYZ xyz = boundingBoxPoint - (group.Location as LocationPoint).Point;
					ElementTransformUtils.MoveElement(useDoc, group.Id, location.Position - (group.Location as LocationPoint).Point - xyz);
					result = true;
				}
				else
				{
					XYZ xyz2 = location.Position - boundingBoxPoint;
					foreach (TextNote textNote in lstTextNote)
					{
						textNote.Coord += xyz2;
					}
					result = true;
				}
			}
			catch (Exception)
			{
				result = false;
			}
			return result;
		}

		private static void CalculateBox(Autodesk.Revit.DB.View inputView, List<TextNote> lstInputTextNote, double rowPitch, out BoundingBoxXYZ resultBoundingBox, out double textWidth, out double textHeight)
		{
			resultBoundingBox = null;
			Transform transform = Transform.CreateTranslation(XYZ.Zero);
			transform.BasisX = inputView.RightDirection;
			transform.BasisY = inputView.UpDirection;
			transform.BasisZ = inputView.ViewDirection;
			transform.Origin = inputView.Origin;
			List<KeyValuePair<TextNote, List<XYZ>>> list = new List<KeyValuePair<TextNote, List<XYZ>>>();
			foreach (TextNote inputText in lstInputTextNote)
			{
				list.Add(MultilineText.CalCulateTextNotePoints(inputText, inputView));
			}
			List<XYZ> list2 = new List<XYZ>();
			foreach (KeyValuePair<TextNote, List<XYZ>> keyValuePair in list)
			{
				foreach (XYZ point in keyValuePair.Value)
				{
					list2.Add(XYZUtilityMethod.TransformPoint(point, transform.Inverse));
				}
			}
			List<XYZ> list3 = new List<XYZ>();
			list3 = (from k in list2
			orderby k.X
			select k).ToList<XYZ>();
			List<XYZ> list4 = new List<XYZ>();
			list4 = (from k in list2
			orderby k.Y
			select k).ToList<XYZ>();
			XYZ xyz = new XYZ(list3[list3.Count - 1].X, list4[list4.Count - 1].Y, list3[0].Z);
			xyz = XYZUtilityMethod.TransformPoint(xyz, transform);
			XYZ xyz2 = new XYZ(list3[0].X, list4[0].Y, list3[0].Z);
			xyz2 = XYZUtilityMethod.TransformPoint(xyz2, transform);
			resultBoundingBox = new BoundingBoxXYZ();
			resultBoundingBox.Max = xyz;
			resultBoundingBox.Min = xyz2;
			List<TextNote> source = (from t in lstInputTextNote
			orderby t.Width
			select t).ToList<TextNote>();
			textWidth = source.Last<TextNote>().Width * (double)inputView.Scale;
			textHeight = lstInputTextNote.First<TextNote>().Height * 0.875 * (double)inputView.Scale * (double)lstInputTextNote.Count + rowPitch * (double)lstInputTextNote.Count - 1.0;
		}

		private static KeyValuePair<TextNote, List<XYZ>> CalCulateTextNotePoints(TextNote inputText, Autodesk.Revit.DB.View inputView)
		{
			BoundingBoxXYZ boundingBoxXYZ = inputText.get_BoundingBox(inputView);
			XYZ point = (boundingBoxXYZ.Max + boundingBoxXYZ.Min) / 2.0;
			List<XYZ> list = new List<XYZ>();
			double num = 0.5 * inputText.Width;
			double num2 = 0.5 * inputText.Height;
			num = (double)inputView.Scale * num;
			num2 = (double)inputView.Scale * num2;
			XYZ xyz = XYZ.Zero + inputView.UpDirection * num2 + inputView.RightDirection * num;
			Transform transform = Transform.CreateTranslation(xyz);
			Transform transform2 = Transform.CreateTranslation(-xyz);
			list.Add(XYZUtilityMethod.TransformPoint(point, transform));
			list.Add(XYZUtilityMethod.TransformPoint(point, transform2));
			return new KeyValuePair<TextNote, List<XYZ>>(inputText, list);
		}

		private static XYZ GetBoundingBoxPoint(AlignType align, BoundingBoxXYZ multiTextBox, Autodesk.Revit.DB.View multiTextView)
		{
			XYZ upDirection = multiTextView.UpDirection;
			XYZ rightDirection = multiTextView.RightDirection;
			switch (align)
			{
			case AlignType.LeftTop:
				return Line.CreateUnbound(multiTextBox.Max, rightDirection).Project(multiTextBox.Min).XYZPoint;
			case AlignType.RightTop:
				return multiTextBox.Max;
			case AlignType.LeftBottom:
				return multiTextBox.Min;
			case AlignType.RightBottom:
				return Line.CreateUnbound(multiTextBox.Min, rightDirection).Project(multiTextBox.Max).XYZPoint;
			case AlignType.Center:
				return (multiTextBox.Max + multiTextBox.Min) / 2.0;
			default:
				return null;
			}
		}
	}
}
